<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../common/common.jsp"%>
<title>商品修改</title>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form" action="" method="post">
       <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品分类：</label>
            <div class="formControls col-xs-8 col-sm-8">
               <span class="select-box">
					<select id="productCategoryId" name="productCategoryId" class="select" required>
						<option value="${defProductCategory.id}">${defProductCategory.name}</option>
						<c:forEach items="${categoryList}" var="category">
							<option value="${category.id}">${category.name}</option>
						</c:forEach>
					</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>供应商ID：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.supplierId}" placeholder="" id="supplierId" name="supplierId" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.sort}" placeholder="" id="sort" name="sort" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品名称：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.name}" placeholder="" id="name" name="name" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图片链接：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.imgUrl}" placeholder="" id="imgUrl" name="imgUrl" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>详情链接：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.detailUrl}" placeholder="" id="detailUrl" name="detailUrl" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>外部链接：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.outUrl}" placeholder="" id="outUrl" name="outUrl" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>单位：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.unit}" placeholder="" id="unit" name="unit" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>成本：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.cost}" placeholder="" id="cost" name="cost" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span> 初始运费：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.startFreight}" id="startFreight" name="startFreight" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span> 单位运费：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.unitFreight}" id="unitFreight" name="unitFreight" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span> 限购数量：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.limitUnit}" id="limitUnit" name="limitUnit" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>粉丝价：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.fansPrice}" id="fansPrice" name="fansPrice" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>会员价：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.baseVipPrice}" placeholder="" id="baseVipPrice" name="baseVipPrice" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>代理价：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.highVipPrice}" placeholder="" id="highVipPrice" name="highVipPrice" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级会员贝币分成：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.chiefBaseVipJinBi}" placeholder="" id="chiefBaseVipJinBi" name="chiefBaseVipJinBi" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级代理贝币分成：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.chiefHighVipJinBi}" placeholder="" id="chiefHighVipJinBi" name="chiefHighVipJinBi" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级会员积分分成：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.chiefBaseVipPoint}" placeholder="" id="chiefBaseVipPoint" name="chiefBaseVipPoint" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级代理积分分成：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.chiefHighVipPoint}" placeholder="" id="chiefHighVipPoint" name="chiefHighVipPoint" required="true">
            </div>
        </div>
                <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>粉丝购赠上代额外贝币：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.fansBuyGiveOtherJb}" placeholder="" id="fansBuyGiveOtherJb" name="fansBuyGiveOtherJb" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>会员购赠上代额外贝币：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.baseVipBuyGiveOtherJb}" placeholder="" id="baseVipBuyGiveOtherJb" name="baseVipBuyGiveOtherJb" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>代理购赠上代额外贝币：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.highVipBuyGiveOtherJb}" placeholder="" id="highVipBuyGiveOtherJb" name="highVipBuyGiveOtherJb" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">描述：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.description}" placeholder="" id="description" name="description">
            </div>
        </div>
         <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${product.remark}" placeholder="" id="remark" name="remark" >
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否推荐：</label>
            <div class="formControls col-xs-8 col-sm-8">
               <span class="select-box">
					<select id="tuiJian" name="tuiJian" class="select" required>
						<option value="${tuijian1}">${tuijian1Str}</option>
						<option value="${tuijian2}">${tuijian2Str}</option>
					</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-8 col-xs-offset-4 col-sm-offset-3">
                <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
            </div>
        </div>
    </form>
</article>

<script type="text/javascript">
$(document).ready(function () {
	 var id = "${productId}";
	 $('#form').bind('submit', function () {
			var productCategoryId = $("#productCategoryId").val();
			var sort = $("#sort").val();
			var supplierId = $("#supplierId").val();
			var name = $("#name").val();
			var imgUrl = $("#imgUrl").val();
			var detailUrl = $("#detailUrl").val();
			var outUrl = $("#outUrl").val();
			var unit = $("#unit").val();
			var cost = $("#cost").val();
			var startFreight = $("#startFreight").val();
			var unitFreight = $("#unitFreight").val();
			var limitUnit = $("#limitUnit").val();
			var fansPrice = $("#fansPrice").val();
			var baseVipPrice = $("#baseVipPrice").val();
			var highVipPrice = $("#highVipPrice").val();
			var chiefBaseVipJinBi = $("#chiefBaseVipJinBi").val();
			var chiefHighVipJinBi = $("#chiefHighVipJinBi").val();
			var chiefBaseVipPoint = $("#chiefBaseVipPoint").val();
			var chiefHighVipPoint = $("#chiefHighVipPoint").val();
			var description = $("#description").val();
			var tuiJian = $("#tuiJian").val();
			var remark = $("#remark").val();
			var fansBuyGiveOtherJb = $("#fansBuyGiveOtherJb").val();
			var baseVipBuyGiveOtherJb = $("#baseVipBuyGiveOtherJb").val();
			var highVipBuyGiveOtherJb = $("#highVipBuyGiveOtherJb").val();

		$.ajax({
			type : 'POST',
			url : ctx + '/productManage/updateProduct.do',
			data : {
				id : id,
				productCategoryId : productCategoryId,
				sort : sort,
				supplierId : supplierId,
				name : name,
				imgUrl : imgUrl,
				detailUrl : detailUrl,
				outUrl : outUrl,
				unit : unit,
				cost : cost,
				startFreight : startFreight,
				unitFreight : unitFreight,
				limitUnit : limitUnit,
				fansPrice : fansPrice,
				baseVipPrice : baseVipPrice,
				highVipPrice : highVipPrice,
				chiefBaseVipJinBi : chiefBaseVipJinBi,
				chiefHighVipJinBi : chiefHighVipJinBi,
				chiefBaseVipPoint : chiefBaseVipPoint,
				chiefHighVipPoint : chiefHighVipPoint,
				highVipPrice : highVipPrice,
				description : description,
				tuiJian : tuiJian,
				fansBuyGiveOtherJb : fansBuyGiveOtherJb,
				baseVipBuyGiveOtherJb : baseVipBuyGiveOtherJb,
				highVipBuyGiveOtherJb : highVipBuyGiveOtherJb,
				remark : remark
			},
			dataType : 'json',
			timeout : 30000,
			context : $('body'),
			success : function(data) {
				if (data.code == "ok") {
                   layer.msg("保存成功!", {icon: 6, time: 1000}, function () {
                   	layer_close();
                   });
				} else {
					 layer.msg(data.msg, {icon: 5, time: 2000});
				}
			},
			error : function(xhr, type) {
				layer.msg('保存失败!', {icon: 5, time: 2000});
			}
		});
		  return false;
	 });
});
</script>
</body>
</html>